<?php
$this->breadcrumbs=array(
	'考试'=>array('index'),
	'考试列表',
);

//$this->menu=array(
//	array('label'=>'待提交', 'url'=>array('index','state'=>'1')),
//	array('label'=>'已提交', 'url'=>array('index','state'=>'2')),
//);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('exams-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'exams-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array('name'=>'exams_name','value'=>'$data->exams_name'),
		array('name'=>'exams_times','filter'=>false),
		array('name'=>'exams_memo','filter'=>false),
		/*
		'exams_id',
		'exams_creater_id',
		'exams_create_time',
		'exams_edit_tims',
		*/
		array(
			'class'=>'CButtonColumn',
			'buttons'=>array(
				'checkIn'=>array(
						    'label'=>'参加考试',     // text label of the button
						    'url'=>'array("check","checkId"=>"$data->exams_id")',
							'visible'=>'Checks::model()->find("checks_user_id=:checks_user_id AND checks_tests_id=:checks_tests_id", array(":checks_user_id"=>Yii::app()->user->id,"checks_tests_id"=>$data->exams_id))==null',
						),
				'checkUp'=>array(
						    'label'=>'等待提交',     // text label of the button
						    'url'=>'array("check","checkId"=>"$data->exams_id")',
							'visible'=>'Checks::model()->find("checks_user_id=:checks_user_id AND checks_tests_id=:checks_tests_id AND checks_status=:checks_status", array(":checks_user_id"=>Yii::app()->user->id,"checks_tests_id"=>$data->exams_id,"checks_status"=>"1")) != null' 
						),
//				'checkDown'=>array(
//						    'label'=>'参考成功',     // text label of the button
//							'url'=>'array("check","checkId"=>"$data->exams_id")',
//							'visible'=>'Checks::model()->find("checks_user_id=:checks_user_id AND checks_tests_id=:checks_tests_id", array(":checks_user_id"=>Yii::app()->user->id,"checks_tests_id"=>$data->exams_id))->checks_status == 2' 
//						),
			),
			//'template'=>'{checkIn}'
			'template'=>'{checkIn}{checkUp}'
		),
	),
)); ?>
